/*
   Copyright (c) 2019 Shanghai Xuanzi Technology Co. Ltd https://xuanzi.ltd
   XZMindMap is licensed under the Mulan PSL v1.
   You can use this software according to the terms and conditions of the Mulan PSL v1.
   You may obtain a copy of Mulan PSL v1 at:
      http://license.coscl.org.cn/MulanPSL
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
   PURPOSE.
   See the Mulan PSL v1 for more details.

*/

package xuanzi.openmind.nodes;

import xuanzi.commons.graphics.Canvas;
import xuanzi.commons.graphics.Paint;
import xuanzi.commons.graphics.BoxF;
import xuanzi.openmind.layout.Box;

public class Background {

	Paint paint = new Paint();
	
	BoxF viewBox;
	
	public Background() {
		// TODO Auto-generated constructor stub
	}

	public void draw(Canvas canvas) {
		paint.fill = true;
		paint.textSize = 11;
		for(int i=-15;i<15;i++) {
			if(i==0)
				paint.borderColor = 0xff000000;
			else
				paint.borderColor = 0x88666666;
			paint.fill = false;
			paint.borderSize = 1;
			float left = Math.max(i*100,viewBox.left);
			left = Math.min(left,viewBox.right);
			float offsetY = Math.max(i*100,viewBox.top);
			offsetY = Math.min(offsetY,viewBox.bottom);
			canvas.drawLine(left, viewBox.top, left, viewBox.bottom, paint);
			canvas.drawLine(viewBox.left,offsetY,  viewBox.right, offsetY, paint);
			paint.fill = true;
			canvas.drawText(i*100+"", i*100, 30, paint);
			canvas.drawText(i*100+"",  30,i*100+10, paint);
		}
	}

	public void setViewBox(Box viewBox) { 
		this.viewBox = viewBox;
	}

}
